package predicate

// C("id").Lt(5)

type Column struct {
	Entity     TableReference // join查询时，每个table需要单独维护自己的model
	ColumnName string
	Alias      string
}

func (c Column) Assignable() {

}

func (c Column) alias() {}

func (c Column) selectable() {
}

func (c Column) expr() {
}

func (c Column) As(alias string) Column {
	return Column{
		ColumnName: c.ColumnName,
		Alias:      alias,
		Entity:     c.Entity,
	}
}

func (c Column) Lt(val any) Predicate {
	return Predicate{
		Op:    OpLt,
		Left:  c,
		Right: ValueOf(val),
	}
}

func (c Column) Gt(val any) Predicate {
	return Predicate{
		Op:    OpGt,
		Left:  c,
		Right: ValueOf(val),
	}
}

func (c Column) Eq(val any) Predicate {
	return Predicate{
		Op:    OpEqual,
		Left:  c,
		Right: ValueOf(val),
	}
}

func (c Column) Le(val any) Predicate {
	return Predicate{
		Op:    OpLe,
		Left:  c,
		Right: ValueOf(val),
	}
}

func (c Column) Ge(val any) Predicate {
	return Predicate{
		Op:    OpGe,
		Left:  c,
		Right: ValueOf(val),
	}
}

func (c Column) InQuery(query SubQuery) Predicate {
	return Predicate{
		Left:  c,
		Op:    SubQueryOpIn,
		Right: query,
	}
}

func C(columnName string) Column {
	return Column{
		ColumnName: columnName,
	}
}

var _ Expression = Column{}
var _ Selectable = Column{}
var _ Alias = Column{}
